/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    const map<string, int> digits{
    {"zero", 0},
    {"one", 1},
    {"two", 2},
    {"three", 3},
    {"four", 4},
    {"five", 5},
    {"six", 6},
    {"seven", 7},
    {"eight", 8},
    {"nine", 9},
};


    string line;
    getline(cin, line);
    if (line.back() != ' ') {
        line.push_back(' ');
    }

    vector<string> words;
    string word;
    for (char c : line) {
        if (c == ' ') {
            words.push_back(word);
            word = "";
        } else {
            word.push_back(c);
        }
    }

    if (words.size() != 3 || words[0] == "zero") {
        cout << "Wrong input" << '\n';
        return 0;
    }
    
vector<int> ns;
    for (string word : words) {
        if (digits.find(word) == digits.end()) {
            cout << "Wrong input" << '\n';
            return 0;
        }
        ns.push_back(digits.at(word));
    }
    int n = 100 * ns[0] + 10 * ns[1] + ns[2];
   // cout<< n<<'\n';
int i, j, x,f;
vector<int> pr;
for (i=100;i<1000;i++){
    f = 1;
    for (x=2;x<i;x++){
        if (i%x == 0){
            f = 0;
            break;
        }
    }
    if (f==1)
        {
        pr.push_back(i);}
}
for (int h = 0;h<pr.size();h++){
    if(n==pr[h]){
    cout<<n;}}
   // break;}

    //for (int j = 0;j<pr.size();j++){
        //cout<<pr[j]<<' ';
    //}
    int prime_less(int n) 
    int prime = 0;
    for (int i = n-1; i >= 2; i--) {
        if (int is_prime(i)) {
            prime = i;
            break;}}
    int prime_more(int n) 
    int prime = 0;
    for (int i = n+1; i <1000 ; i++) {
        if (int is_prime(i)) {
         prime = i;
            break;
        }
    }
int n_less =prime_less(n);
    int n_more = prime_more(n);
    if (abs (n - n_more) <= abs (n-n_less))
        cout <<  "Ближайшее простое число: " << n_more << endl;
    else
        cout <<  "Ближайшее простое число: " << n_less << endl;
    return 0;
}

   
